<template>
    <div id="AddNewStudent">
        <table class="table table-bordered">
            <tbody>
               <tr>
                   <td>姓名</td>
                   <td>
                       <el-input v-model="studentInfo.name"></el-input>
                   </td>
                   <td>性别</td>
                   <td>
                        <el-select  v-model="studentInfo.gender">
                            <el-option label="男" value=1></el-option>
                            <el-option label="女" value=0></el-option>
                        </el-select>
                   </td>
               </tr>
               <tr>
                   <td>电话</td>
                   <td>
                       <el-input v-model="studentInfo.mobile"></el-input>
                   </td>
                   <td>邮箱</td>
                   <td>
                       <el-input v-model="studentInfo.email"></el-input>
                   </td>
               </tr>
               <tr>
                   <td>QQ</td>
                   <td>
                       <el-input v-model="studentInfo.qq"></el-input>
                   </td>
                   <td>微信</td>
                   <td>
                       <el-input v-model="studentInfo.wx"></el-input>
                   </td>
               </tr>
               <tr>
                   <td>状态</td>
                   <td>
                    <el-select v-model="studentInfo.status" placeholder="请选择" @click.native="loadData('social_status')">
                        <el-option v-for="item in social_status "
                        :key="item.kvalue"
                        :label="item.kvalue"
                        :value="item.kkey"
                        ></el-option>
                    </el-select>
                   </td>
                   <td>报名科目</td>
                   <td>
                       <el-input v-model="studentInfo.subject"></el-input>
                   </td>
               </tr>
               <tr>
                   <td>报名费</td>
                   <td>
                       <el-input v-model="studentInfo.entryFee"></el-input>
                   </td>
                   <td>学费</td>
                   <td>
                       <el-input v-model="studentInfo.tuitionFee"></el-input>
                   </td>
               </tr>
               <tr>
                   <td>咨询师</td>
                   <td>
                       <el-input v-model="studentInfo.advisor"></el-input>
                   </td>
                   <td>推荐费</td>
                   <td>
                       <el-input v-model="studentInfo.recommonendFee"></el-input>
                   </td>
               </tr>
               <tr>
                   <td>毕业学校</td>
                   <td>
                       <el-input v-model="studentInfo.graduateFrom"></el-input>
                   </td>
                   <td>毕业年限</td>
                   <td>
                       <el-input v-model="studentInfo.graduateYear"></el-input>
                   </td>
               </tr>
               <tr>
                   <td>学历</td>
                   <td>
                        <el-select v-model="studentInfo.education" placeholder="请选择" @click.native="loadData('education')">
                            <el-option v-for="item in education "
                            :key="item.kvalue"
                            :label="item.kvalue"
                            :value="item.kkey"
                            ></el-option>
                        </el-select>
                   </td>
                   <td></td>
                   <td></td>
               </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="4" style="text-align:center">
                        <el-button type="danger" @click="cancel">取消</el-button>
                        <el-button type="primary" @click="submit">提交</el-button>
                    </td>
                </tr>
            </tfoot>
        </table>
    </div>
</template>

<script>
export default {
    data(){
        return {
            studentInfo: {
                name: '',
                gender: '',
                mobile: '',
                email: '',
                qq: '',
                wx: '',
                status: [],
                subject: '',
                entryFee: '',
                tuitionFee: '',
                advisor: '',
                recommonendFee: '',
                graduateFrom: '',
                graduateYear: '',
                education: '',
            },
            education: [],
            social_status: []
        }
    },
    methods: {
        cancel(){
            this.$router.go(-1)
        },
        submit(){
            // /backstage/reputation/insert
            var insertURL = window.baseURL + "/backstage/reputation/insert";
            this.studentInfo.token = this.$token;
            this.$http.post(insertURL,this.$qs.stringify(this.studentInfo))
            .then((res)=>{
            })
            .catch((error)=>{
            })
        },
        loadData(type){
            /*
            type: 
                education 
                occupation 
                social_status
                source
            */ 
            var sourceURL = window.baseURL+"/backstage/config/findConfigs?ktype="+type+"&token="+this.$token
            this.$http.get(sourceURL)
            .then((response)=>{
                this[type] = response.data.data;
            })
            .catch((error)=>{
            })
        }
    }
}
</script>

<style lang="scss" scoped>
    #AddNewStudent{
         width: 100%;
        height: 100%;
        padding: 40px;
    }
</style>
